//
//  BaiHatTheoCaSiViewController.m
//  NhomThuy
//
//  Created by HOCVIEN on 1/27/15.
//  Copyright (c) 2015 t3h. All rights reserved.
//

#import "BaiHatTheoCaSiViewController.h"
#import "ManagerData.h"
#import "BaiHatTheoCaSiCell.h"
@interface BaiHatTheoCaSiViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation BaiHatTheoCaSiViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    self.danhSachBaiHat.delegate=self;
    self.danhSachBaiHat.dataSource = self;
}
- (void)viewWillAppear:(BOOL)animated{
    self.songListBySinger = [[ManagerData defaultManager] getSongListBySingerID:self.singerID];
    [UINavigationBar appearance];
    [self.navigationController.navigationBar setBarTintColor:[[ManagerData defaultManager] setBackgroundColorForNavi]];
    [self.navigationController.navigationBar setTintColor:[[ManagerData defaultManager] setTintColorForNavi]];
    //add name of singer
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont boldSystemFontOfSize:18.0];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [[ManagerData defaultManager]setTintColorForNavi]; // change this color
    self.navigationItem.titleView = label;
    label.text = self.singerName;
    [label sizeToFit];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *cellID=@"BaiHatTheoCaSi_CellID";
    BaiHatTheoCaSiCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(!cell){
        [tableView registerClass:[BaiHatTheoCaSiCell class] forCellReuseIdentifier:cellID];
    }
    NSDictionary *detail = [self.songListBySinger objectAtIndex:indexPath.row];
    cell.tenBaiHat.text = [[detail objectForKey:@"song-name"] capitalizedString];
    cell.maBaiHat.text = [detail objectForKey:@"song-code"];
    cell.noiDung.text = [detail objectForKey:@"lyrics"];
    
    return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.songListBySinger.count;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 79;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 85;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
